1 : <?php
2 : /**
3 : * Smarty Template Lexer
4 : *
5 : * This is the lexer to break the template source into tokens
6 : * @package Smarty
7 : * @subpackage Compiler
8 : * @author Uwe Tews
9 : */
10 : /**
11 : * Smarty Template Lexer
12 : */
13 : class Smarty_Compiler_Template_Lexer extends Smarty_Exception_Magic
14 1 : {
15 : public $data = null;
16 : public $counter = null;
17 : public $token = null;
18 : public $value = null;
19 : public $node = null;
20 : public $line = 0;
21 : public $taglineno = 1;
22 : public $line_offset = 0;
23 : public $state = 1;
24 : public $compiler;
25 : Public $ldel;
26 : Public $rdel;
27 : Public $rdel_length;
28 : Public $ldel_length;
29 : Public $mbstring_overload;
30 : private $heredoc_id_stack = Array();
31 : public $smarty_token_names = array ( // Text for parser error messages
32 : 'IDENTITY' => '===',
33 : 'NONEIDENTITY' => '!==',
34 : 'EQUALS' => '==',
35 : 'NOTEQUALS' => '!=',
36 : 'GREATEREQUAL' => '(>=,ge)',
37 : 'LESSEQUAL' => '(<=,le)',
38 : 'GREATERTHAN' => '(>,gt)',
39 : 'LESSTHAN' => '(<,lt)',
40 : 'MOD' => '(%,mod)',
41 : 'NOT' => '(!,not)',
42 : 'LAND' => '(&&,and)',
43 : 'LOR' => '(||,or)',
44 : 'LXOR' => 'xor',
45 : 'OPENP' => '(',
46 : 'CLOSEP' => ')',
47 : 'OPENB' => '[',
48 : 'CLOSEB' => ']',
49 : 'PTR' => '->',
50 : 'APTR' => '=>',
51 : 'EQUAL' => '=',
52 : 'NUMBER' => 'number',
53 : 'UNIMATH' => '+" , "-',
54 : 'MATH' => '*" , "/" , "%',
55 : 'SPACE' => ' ',
56 : 'DOLLAR' => '$',
57 : 'SEMICOLON' => ';',
58 : 'COLON' => ':',
59 : 'DOUBLECOLON' => '::',
60 : 'AT' => '@',
61 : 'HATCH' => '#',
62 : 'QUOTE' => '"',
63 : 'BACKTICK' => '`',
64 : 'VERT' => '|',
65 : 'DOT' => '.',
66 : 'COMMA' => '","',
67 : 'ANDSYM' => '"&"',
68 : 'QMARK' => '"?"',
69 : 'ID' => 'identifier',
70 : 'TEXT' => 'text',
71 : 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
72 : 'PHPSTARTTAG' => 'PHP start tag',
73 : 'PHPENDTAG' => 'PHP end tag',
74 : 'LITERALSTART' => 'Literal start',
75 : 'LITERALEND' => 'Literal end',
76 : 'LDELSLASH' => 'closing tag',
77 : 'COMMENT' => 'comment',
78 : 'AS' => 'as',
79 : 'TO' => 'to',
80 : );
81 :
82 :
83 : function __construct($data,$compiler)
84 : {
85 : // $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
86 :
87 905 : if ($data !==null){
88 0 : $this->data = $data;
89 0 : }
90 905 : $this->counter = 0;
91 905 : $this->line = 1;
92 905 : $this->line_offset = $compiler->line_offset;
93 905 : $this->compiler = $compiler;
94 905 : $this->ldel = preg_quote($this->compiler->tpl_obj->left_delimiter,'/');
95 905 : $this->ldel_length = strlen($this->compiler->tpl_obj->left_delimiter);
96 905 : $this->rdel = preg_quote($this->compiler->tpl_obj->right_delimiter,'/');
97 905 : $this->rdel_length = strlen($this->compiler->tpl_obj->right_delimiter);
98 905 : $this->smarty_token_names['LDEL'] = $this->compiler->tpl_obj->left_delimiter;
99 905 : $this->smarty_token_names['RDEL'] = $this->compiler->tpl_obj->right_delimiter;
100 905 : $this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
101 905 : }
102 :
103 :
104 : private $_yy_state = 1;
105 : private $_yy_stack = array();
106 :
107 : public function yylex()
108 : {
109 896 : return $this->{'yylex' . $this->_yy_state}();
110 : }
111 :
112 : public function yypushstate($state)
113 : {
114 895 : array_push($this->_yy_stack, $this->_yy_state);
115 895 : $this->_yy_state = $state;
116 895 : }
117 :
118 : public function yypopstate()
119 : {
120 820 : $this->_yy_state = array_pop($this->_yy_stack);
121 820 : }
122 :
123 : public function yybegin($state)
124 : {
125 0 : $this->_yy_state = $state;
126 0 : }
127 :
128 :
129 :
130 : public function yylex1()
131 : {
132 : $tokenMap = array (
133 896 : 1 => 0,
134 896 : 2 => 0,
135 896 : );
136 896 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
137 1 : return false; // end of input
138 : }
139 895 : $yy_global_pattern = "/\G(\xEF\xBB\xBF|\xFE\xFF|\xFF\xFE)|\G([\s\S]?)/iS";
140 :
141 : do {
142 895 : if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
143 895 : $yysubmatches = $yymatches;
144 895 : $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
145 895 : if (!count($yymatches)) {
146 0 : throw new Exception('Error: lexing failed because a rule matched' .
147 0 : ' an empty string. Input "' . substr($this->data,
148 0 : $this->counter, 5) . '... state BOM');
149 : }
150 895 : next($yymatches); // skip global match
151 895 : $this->token = key($yymatches); // token number
152 895 : if ($tokenMap[$this->token]) {
153 : // extract sub-patterns for passing to lex function
154 0 : $yysubmatches = array_slice($yysubmatches, $this->token + 1,
155 0 : $tokenMap[$this->token]);
156 0 : } else {
157 895 : $yysubmatches = array();
158 : }
159 895 : $this->value = current($yymatches); // token value
160 895 : $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
161 895 : if ($r === null) {
162 895 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
163 895 : $this->line += substr_count($this->value, "\n");
164 : // accept this token
165 895 : return true;
166 0 : } elseif ($r === true) {
167 : // we have changed state
168 : // process this token in the new state
169 0 : return $this->yylex();
170 0 : } elseif ($r === false) {
171 0 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
172 0 : $this->line += substr_count($this->value, "\n");
173 0 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
174 0 : return false; // end of input
175 : }
176 : // skip this token
177 0 : continue;
178 0 : } } else {
179 0 : throw new Exception('Unexpected input at line' . $this->line .
180 0 : ': ' . $this->data[$this->counter]);
181 : }
182 0 : break;
183 0 : } while (true);
184 :
185 0 : } // end function
186 :
187 :
188 : const BOM = 1;
189 : function yy_r1_1($yy_subpatterns)
190 : {
191 :
192 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEMPLATEINIT;
193 0 : $this->yypushstate(self::TEXT);
194 0 : }
195 : function yy_r1_2($yy_subpatterns)
196 : {
197 :
198 895 : $this->value = '';
199 895 : $this->token = Smarty_Compiler_Template_Parser::TP_TEMPLATEINIT;
200 895 : $this->yypushstate(self::TEXT);
201 895 : }
202 :
203 :
204 : public function yylex2()
205 : {
206 : $tokenMap = array (
207 895 : 1 => 0,
208 895 : 2 => 0,
209 895 : 3 => 0,
210 895 : 4 => 0,
211 895 : 5 => 0,
212 895 : 6 => 0,
213 895 : 7 => 1,
214 895 : 9 => 2,
215 895 : 12 => 1,
216 895 : 14 => 1,
217 895 : 16 => 1,
218 895 : 18 => 1,
219 895 : 20 => 1,
220 895 : 22 => 1,
221 895 : 24 => 0,
222 895 : 25 => 0,
223 895 : 26 => 1,
224 895 : 28 => 0,
225 895 : 29 => 0,
226 895 : 30 => 0,
227 895 : );
228 895 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
229 853 : return false; // end of input
230 : }
231 895 : $yy_global_pattern = "/\G(\\{\\})|\G(".$this->ldel."strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s{1,}\/)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*(if|elseif|else if|while)\\s+)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*for\\s+)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*foreach(?![^\s]))|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*setfilter\\s+)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s{1,})|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\/)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel."))|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G((".$this->rdel."|--".$this->rdel."\\s*|-".$this->rdel."[^\S\r\n]*))|\G(<%)|\G(%>)|\G([\S\s])/iS";
232 :
233 : do {
234 895 : if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
235 895 : $yysubmatches = $yymatches;
236 895 : $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
237 895 : if (!count($yymatches)) {
238 0 : throw new Exception('Error: lexing failed because a rule matched' .
239 0 : ' an empty string. Input "' . substr($this->data,
240 0 : $this->counter, 5) . '... state TEXT');
241 : }
242 895 : next($yymatches); // skip global match
243 895 : $this->token = key($yymatches); // token number
244 895 : if ($tokenMap[$this->token]) {
245 : // extract sub-patterns for passing to lex function
246 820 : $yysubmatches = array_slice($yysubmatches, $this->token + 1,
247 820 : $tokenMap[$this->token]);
248 820 : } else {
249 365 : $yysubmatches = array();
250 : }
251 895 : $this->value = current($yymatches); // token value
252 895 : $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
253 895 : if ($r === null) {
254 895 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
255 895 : $this->line += substr_count($this->value, "\n");
256 : // accept this token
257 895 : return true;
258 0 : } elseif ($r === true) {
259 : // we have changed state
260 : // process this token in the new state
261 0 : return $this->yylex();
262 0 : } elseif ($r === false) {
263 0 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
264 0 : $this->line += substr_count($this->value, "\n");
265 0 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
266 0 : return false; // end of input
267 : }
268 : // skip this token
269 0 : continue;
270 0 : } } else {
271 0 : throw new Exception('Unexpected input at line' . $this->line .
272 0 : ': ' . $this->data[$this->counter]);
273 : }
274 0 : break;
275 0 : } while (true);
276 :
277 0 : } // end function
278 :
279 :
280 : const TEXT = 2;
281 : function yy_r2_1($yy_subpatterns)
282 : {
283 :
284 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
285 0 : }
286 : function yy_r2_2($yy_subpatterns)
287 : {
288 :
289 1 : $this->token = Smarty_Compiler_Template_Parser::TP_STRIPON;
290 1 : }
291 : function yy_r2_3($yy_subpatterns)
292 : {
293 :
294 0 : if ($this->compiler->tpl_obj->auto_literal) {
295 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
296 0 : } else {
297 0 : $this->token = Smarty_Compiler_Template_Parser::TP_STRIPON;
298 : }
299 0 : }
300 : function yy_r2_4($yy_subpatterns)
301 : {
302 :
303 1 : $this->token = Smarty_Compiler_Template_Parser::TP_STRIPOFF;
304 1 : }
305 : function yy_r2_5($yy_subpatterns)
306 : {
307 :
308 0 : if ($this->compiler->tpl_obj->auto_literal) {
309 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
310 0 : } else {
311 0 : $this->token = Smarty_Compiler_Template_Parser::TP_STRIPOFF;
312 : }
313 0 : }
314 : function yy_r2_6($yy_subpatterns)
315 : {
316 :
317 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LITERALSTART;
318 0 : $this->yypushstate(self::LITERAL);
319 0 : }
320 : function yy_r2_7($yy_subpatterns)
321 : {
322 :
323 0 : if ($this->compiler->tpl_obj->auto_literal) {
324 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
325 0 : } else {
326 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELSLASH;
327 0 : $this->yypushstate(self::SMARTY);
328 0 : $this->taglineno = $this->line + $this->line_offset;
329 : }
330 0 : }
331 : function yy_r2_9($yy_subpatterns)
332 : {
333 :
334 95 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
335 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
336 0 : } else {
337 95 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELIF;
338 95 : $this->yypushstate(self::SMARTY);
339 95 : $this->taglineno = $this->line + $this->line_offset;
340 : }
341 95 : }
342 : function yy_r2_12($yy_subpatterns)
343 : {
344 :
345 17 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
346 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
347 0 : } else {
348 17 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELFOR;
349 17 : $this->yypushstate(self::SMARTY);
350 17 : $this->taglineno = $this->line + $this->line_offset;
351 : }
352 17 : }
353 : function yy_r2_14($yy_subpatterns)
354 : {
355 :
356 41 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
357 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
358 0 : } else {
359 41 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELFOREACH;
360 41 : $this->yypushstate(self::SMARTY);
361 41 : $this->taglineno = $this->line + $this->line_offset;
362 : }
363 41 : }
364 : function yy_r2_16($yy_subpatterns)
365 : {
366 :
367 1 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
368 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
369 0 : } else {
370 1 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELSETFILTER;
371 1 : $this->yypushstate(self::SMARTY);
372 1 : $this->taglineno = $this->line + $this->line_offset;
373 : }
374 1 : }
375 : function yy_r2_18($yy_subpatterns)
376 : {
377 :
378 1 : if ($this->compiler->tpl_obj->auto_literal) {
379 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
380 0 : } else {
381 1 : $this->token = Smarty_Compiler_Template_Parser::TP_LDEL;
382 1 : $this->yypushstate(self::SMARTY);
383 1 : $this->taglineno = $this->line + $this->line_offset;
384 : }
385 1 : }
386 : function yy_r2_20($yy_subpatterns)
387 : {
388 :
389 233 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELSLASH;
390 233 : $this->yypushstate(self::SMARTY);
391 233 : $this->taglineno = $this->line + $this->line_offset;
392 233 : }
393 : function yy_r2_22($yy_subpatterns)
394 : {
395 :
396 815 : $this->token = Smarty_Compiler_Template_Parser::TP_LDEL;
397 815 : $this->yypushstate(self::SMARTY);
398 815 : $this->taglineno = $this->line + $this->line_offset;
399 815 : }
400 : function yy_r2_24($yy_subpatterns)
401 : {
402 :
403 9 : if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
404 3 : $this->token = Smarty_Compiler_Template_Parser::TP_PHPSTARTTAG;
405 9 : } elseif ($this->value == '<?xml') {
406 6 : $this->token = Smarty_Compiler_Template_Parser::TP_XMLTAG;
407 6 : } else {
408 0 : $this->token = Smarty_Compiler_Template_Parser::TP_FAKEPHPSTARTTAG;
409 0 : $this->value = substr($this->value, 0, 2);
410 : }
411 9 : }
412 : function yy_r2_25($yy_subpatterns)
413 : {
414 :
415 8 : $this->token = Smarty_Compiler_Template_Parser::TP_PHPENDTAG;
416 8 : }
417 : function yy_r2_26($yy_subpatterns)
418 : {
419 :
420 1 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
421 1 : }
422 : function yy_r2_28($yy_subpatterns)
423 : {
424 :
425 2 : $this->token = Smarty_Compiler_Template_Parser::TP_ASPSTARTTAG;
426 2 : }
427 : function yy_r2_29($yy_subpatterns)
428 : {
429 :
430 2 : $this->token = Smarty_Compiler_Template_Parser::TP_ASPENDTAG;
431 2 : }
432 : function yy_r2_30($yy_subpatterns)
433 : {
434 :
435 365 : if ($this->mbstring_overload) {
436 0 : $to = mb_strlen($this->data,'latin1');
437 0 : } else {
438 365 : $to = strlen($this->data);
439 : }
440 365 : preg_match("/\s*{$this->ldel}--|[^\S\r\n]*{$this->ldel}-|{$this->ldel}|<\?|\?>|<%|%>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
441 365 : if (isset($match[0][1])) {
442 279 : $to = $match[0][1];
443 279 : }
444 365 : if ($this->mbstring_overload) {
445 0 : $this->value = mb_substr($this->data,$this->counter,$to-$this->counter,'latin1');
446 0 : } else {
447 365 : $this->value = substr($this->data,$this->counter,$to-$this->counter);
448 : }
449 365 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
450 365 : }
451 :
452 :
453 : public function yylex3()
454 : {
455 : $tokenMap = array (
456 820 : 1 => 0,
457 820 : 2 => 1,
458 820 : 4 => 2,
459 820 : 7 => 1,
460 820 : 9 => 1,
461 820 : 11 => 1,
462 820 : 13 => 1,
463 820 : 15 => 1,
464 820 : 17 => 1,
465 820 : 19 => 1,
466 820 : 21 => 2,
467 820 : 24 => 0,
468 820 : 25 => 0,
469 820 : 26 => 0,
470 820 : 27 => 0,
471 820 : 28 => 0,
472 820 : 29 => 0,
473 820 : 30 => 0,
474 820 : 31 => 0,
475 820 : 32 => 1,
476 820 : 34 => 1,
477 820 : 36 => 1,
478 820 : 38 => 0,
479 820 : 39 => 0,
480 820 : 40 => 0,
481 820 : 41 => 0,
482 820 : 42 => 0,
483 820 : 43 => 0,
484 820 : 44 => 0,
485 820 : 45 => 0,
486 820 : 46 => 0,
487 820 : 47 => 0,
488 820 : 48 => 0,
489 820 : 49 => 0,
490 820 : 50 => 0,
491 820 : 51 => 0,
492 820 : 52 => 0,
493 820 : 53 => 0,
494 820 : 54 => 0,
495 820 : 55 => 3,
496 820 : 59 => 0,
497 820 : 60 => 0,
498 820 : 61 => 0,
499 820 : 62 => 0,
500 820 : 63 => 0,
501 820 : 64 => 0,
502 820 : 65 => 0,
503 820 : 66 => 1,
504 820 : 68 => 1,
505 820 : 70 => 1,
506 820 : 72 => 0,
507 820 : 73 => 0,
508 820 : 74 => 0,
509 820 : 75 => 0,
510 820 : 76 => 0,
511 820 : 77 => 0,
512 820 : 78 => 0,
513 820 : 79 => 0,
514 820 : 80 => 0,
515 820 : 81 => 0,
516 820 : 82 => 0,
517 820 : 83 => 0,
518 820 : 84 => 0,
519 820 : 85 => 0,
520 820 : 86 => 0,
521 820 : 87 => 0,
522 820 : 88 => 0,
523 820 : 89 => 0,
524 820 : 90 => 1,
525 820 : 92 => 0,
526 820 : );
527 820 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
528 0 : return false; // end of input
529 : }
530 820 : $yy_global_pattern = "/\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s{1,}\/)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*(if|elseif|else if|while)\\s+)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*for\\s+)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*foreach(?![^\s]))|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s{1,})|\G(\\s{1,}(".$this->rdel."|--".$this->rdel."\\s*|-".$this->rdel."[^\S\r\n]*))|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\/)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel."))|\G((".$this->rdel."|--".$this->rdel."\\s*|-".$this->rdel."[^\S\r\n]*))|\G(\\*([\S\s]*?)\\*(?=(".$this->rdel."|--".$this->rdel."\\s*|-".$this->rdel."[^\S\r\n]*)))|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(\\$[0-9]*[a-zA-Z_]\\w*(\\+\\+|--))|\G(\\$)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(@)|\G(#)|\G(\")|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*=\\s*)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(\\s+)|\G((\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([\S\s])/iS";
531 :
532 : do {
533 820 : if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
534 820 : $yysubmatches = $yymatches;
535 820 : $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
536 820 : if (!count($yymatches)) {
537 0 : throw new Exception('Error: lexing failed because a rule matched' .
538 0 : ' an empty string. Input "' . substr($this->data,
539 0 : $this->counter, 5) . '... state SMARTY');
540 : }
541 820 : next($yymatches); // skip global match
542 820 : $this->token = key($yymatches); // token number
543 820 : if ($tokenMap[$this->token]) {
544 : // extract sub-patterns for passing to lex function
545 820 : $yysubmatches = array_slice($yysubmatches, $this->token + 1,
546 820 : $tokenMap[$this->token]);
547 820 : } else {
548 810 : $yysubmatches = array();
549 : }
550 820 : $this->value = current($yymatches); // token value
551 820 : $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
552 820 : if ($r === null) {
553 820 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
554 820 : $this->line += substr_count($this->value, "\n");
555 : // accept this token
556 820 : return true;
557 0 : } elseif ($r === true) {
558 : // we have changed state
559 : // process this token in the new state
560 0 : return $this->yylex();
561 0 : } elseif ($r === false) {
562 0 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
563 0 : $this->line += substr_count($this->value, "\n");
564 0 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
565 0 : return false; // end of input
566 : }
567 : // skip this token
568 0 : continue;
569 0 : } } else {
570 0 : throw new Exception('Unexpected input at line' . $this->line .
571 0 : ': ' . $this->data[$this->counter]);
572 : }
573 0 : break;
574 0 : } while (true);
575 :
576 0 : } // end function
577 :
578 :
579 : const SMARTY = 3;
580 : function yy_r3_1($yy_subpatterns)
581 : {
582 :
583 148 : $this->token = Smarty_Compiler_Template_Parser::TP_SINGLEQUOTESTRING;
584 148 : }
585 : function yy_r3_2($yy_subpatterns)
586 : {
587 :
588 0 : if ($this->compiler->tpl_obj->auto_literal) {
589 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
590 0 : } else {
591 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELSLASH;
592 0 : $this->yypushstate(self::SMARTY);
593 0 : $this->taglineno = $this->line + $this->line_offset;
594 : }
595 0 : }
596 : function yy_r3_4($yy_subpatterns)
597 : {
598 :
599 0 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
600 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
601 0 : } else {
602 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELIF;
603 0 : $this->yypushstate(self::SMARTY);
604 0 : $this->taglineno = $this->line + $this->line_offset;
605 : }
606 0 : }
607 : function yy_r3_7($yy_subpatterns)
608 : {
609 :
610 0 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
611 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
612 0 : } else {
613 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELFOR;
614 0 : $this->yypushstate(self::SMARTY);
615 0 : $this->taglineno = $this->line + $this->line_offset;
616 : }
617 0 : }
618 : function yy_r3_9($yy_subpatterns)
619 : {
620 :
621 0 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
622 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
623 0 : } else {
624 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELFOREACH;
625 0 : $this->yypushstate(self::SMARTY);
626 0 : $this->taglineno = $this->line + $this->line_offset;
627 : }
628 0 : }
629 : function yy_r3_11($yy_subpatterns)
630 : {
631 :
632 0 : if ($this->compiler->tpl_obj->auto_literal) {
633 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
634 0 : } else {
635 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDEL;
636 0 : $this->yypushstate(self::SMARTY);
637 0 : $this->taglineno = $this->line + $this->line_offset;
638 : }
639 0 : }
640 : function yy_r3_13($yy_subpatterns)
641 : {
642 :
643 3 : $this->token = Smarty_Compiler_Template_Parser::TP_RDEL;
644 3 : $this->yypopstate();
645 3 : }
646 : function yy_r3_15($yy_subpatterns)
647 : {
648 :
649 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELSLASH;
650 0 : $this->yypushstate(self::SMARTY);
651 0 : $this->taglineno = $this->line + $this->line_offset;
652 0 : }
653 : function yy_r3_17($yy_subpatterns)
654 : {
655 :
656 7 : $this->token = Smarty_Compiler_Template_Parser::TP_LDEL;
657 7 : $this->yypushstate(self::SMARTY);
658 7 : $this->taglineno = $this->line + $this->line_offset;
659 7 : }
660 : function yy_r3_19($yy_subpatterns)
661 : {
662 :
663 817 : $this->token = Smarty_Compiler_Template_Parser::TP_RDEL;
664 817 : $this->yypopstate();
665 817 : }
666 : function yy_r3_21($yy_subpatterns)
667 : {
668 :
669 14 : $this->token = Smarty_Compiler_Template_Parser::TP_COMMENT;
670 14 : }
671 : function yy_r3_24($yy_subpatterns)
672 : {
673 :
674 0 : $this->token = Smarty_Compiler_Template_Parser::TP_ISIN;
675 0 : }
676 : function yy_r3_25($yy_subpatterns)
677 : {
678 :
679 22 : $this->token = Smarty_Compiler_Template_Parser::TP_AS;
680 22 : }
681 : function yy_r3_26($yy_subpatterns)
682 : {
683 :
684 10 : $this->token = Smarty_Compiler_Template_Parser::TP_TO;
685 10 : }
686 : function yy_r3_27($yy_subpatterns)
687 : {
688 :
689 1 : $this->token = Smarty_Compiler_Template_Parser::TP_STEP;
690 1 : }
691 : function yy_r3_28($yy_subpatterns)
692 : {
693 :
694 0 : $this->token = Smarty_Compiler_Template_Parser::TP_INSTANCEOF;
695 0 : }
696 : function yy_r3_29($yy_subpatterns)
697 : {
698 :
699 8 : $this->token = Smarty_Compiler_Template_Parser::TP_IDENTITY;
700 8 : }
701 : function yy_r3_30($yy_subpatterns)
702 : {
703 :
704 2 : $this->token = Smarty_Compiler_Template_Parser::TP_NONEIDENTITY;
705 2 : }
706 : function yy_r3_31($yy_subpatterns)
707 : {
708 :
709 9 : $this->token = Smarty_Compiler_Template_Parser::TP_EQUALS;
710 9 : }
711 : function yy_r3_32($yy_subpatterns)
712 : {
713 :
714 4 : $this->token = Smarty_Compiler_Template_Parser::TP_NOTEQUALS;
715 4 : }
716 : function yy_r3_34($yy_subpatterns)
717 : {
718 :
719 7 : $this->token = Smarty_Compiler_Template_Parser::TP_GREATEREQUAL;
720 7 : }
721 : function yy_r3_36($yy_subpatterns)
722 : {
723 :
724 4 : $this->token = Smarty_Compiler_Template_Parser::TP_LESSEQUAL;
725 4 : }
726 : function yy_r3_38($yy_subpatterns)
727 : {
728 :
729 13 : $this->token = Smarty_Compiler_Template_Parser::TP_GREATERTHAN;
730 13 : }
731 : function yy_r3_39($yy_subpatterns)
732 : {
733 :
734 29 : $this->token = Smarty_Compiler_Template_Parser::TP_LESSTHAN;
735 29 : }
736 : function yy_r3_40($yy_subpatterns)
737 : {
738 :
739 0 : $this->token = Smarty_Compiler_Template_Parser::TP_MOD;
740 0 : }
741 : function yy_r3_41($yy_subpatterns)
742 : {
743 :
744 2 : $this->token = Smarty_Compiler_Template_Parser::TP_NOT;
745 2 : }
746 : function yy_r3_42($yy_subpatterns)
747 : {
748 :
749 5 : $this->token = Smarty_Compiler_Template_Parser::TP_LAND;
750 5 : }
751 : function yy_r3_43($yy_subpatterns)
752 : {
753 :
754 5 : $this->token = Smarty_Compiler_Template_Parser::TP_LOR;
755 5 : }
756 : function yy_r3_44($yy_subpatterns)
757 : {
758 :
759 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LXOR;
760 0 : }
761 : function yy_r3_45($yy_subpatterns)
762 : {
763 :
764 2 : $this->token = Smarty_Compiler_Template_Parser::TP_ISODDBY;
765 2 : }
766 : function yy_r3_46($yy_subpatterns)
767 : {
768 :
769 0 : $this->token = Smarty_Compiler_Template_Parser::TP_ISNOTODDBY;
770 0 : }
771 : function yy_r3_47($yy_subpatterns)
772 : {
773 :
774 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISODD;
775 1 : }
776 : function yy_r3_48($yy_subpatterns)
777 : {
778 :
779 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISNOTODD;
780 1 : }
781 : function yy_r3_49($yy_subpatterns)
782 : {
783 :
784 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISEVENBY;
785 1 : }
786 : function yy_r3_50($yy_subpatterns)
787 : {
788 :
789 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISNOTEVENBY;
790 1 : }
791 : function yy_r3_51($yy_subpatterns)
792 : {
793 :
794 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISEVEN;
795 1 : }
796 : function yy_r3_52($yy_subpatterns)
797 : {
798 :
799 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISNOTEVEN;
800 1 : }
801 : function yy_r3_53($yy_subpatterns)
802 : {
803 :
804 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISDIVBY;
805 1 : }
806 : function yy_r3_54($yy_subpatterns)
807 : {
808 :
809 1 : $this->token = Smarty_Compiler_Template_Parser::TP_ISNOTDIVBY;
810 1 : }
811 : function yy_r3_55($yy_subpatterns)
812 : {
813 :
814 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TYPECAST;
815 0 : }
816 : function yy_r3_59($yy_subpatterns)
817 : {
818 :
819 48 : $this->token = Smarty_Compiler_Template_Parser::TP_OPENP;
820 48 : }
821 : function yy_r3_60($yy_subpatterns)
822 : {
823 :
824 48 : $this->token = Smarty_Compiler_Template_Parser::TP_CLOSEP;
825 48 : }
826 : function yy_r3_61($yy_subpatterns)
827 : {
828 :
829 79 : $this->token = Smarty_Compiler_Template_Parser::TP_OPENB;
830 79 : }
831 : function yy_r3_62($yy_subpatterns)
832 : {
833 :
834 79 : $this->token = Smarty_Compiler_Template_Parser::TP_CLOSEB;
835 79 : }
836 : function yy_r3_63($yy_subpatterns)
837 : {
838 :
839 11 : $this->token = Smarty_Compiler_Template_Parser::TP_PTR;
840 11 : }
841 : function yy_r3_64($yy_subpatterns)
842 : {
843 :
844 5 : $this->token = Smarty_Compiler_Template_Parser::TP_APTR;
845 5 : }
846 : function yy_r3_65($yy_subpatterns)
847 : {
848 :
849 120 : $this->token = Smarty_Compiler_Template_Parser::TP_EQUAL;
850 120 : }
851 : function yy_r3_66($yy_subpatterns)
852 : {
853 :
854 29 : $this->token = Smarty_Compiler_Template_Parser::TP_UNIMATH;
855 29 : }
856 : function yy_r3_68($yy_subpatterns)
857 : {
858 :
859 5 : $this->token = Smarty_Compiler_Template_Parser::TP_MATH;
860 5 : }
861 : function yy_r3_70($yy_subpatterns)
862 : {
863 :
864 7 : $this->token = Smarty_Compiler_Template_Parser::TP_IDINCDEC;
865 7 : }
866 : function yy_r3_72($yy_subpatterns)
867 : {
868 :
869 378 : $this->token = Smarty_Compiler_Template_Parser::TP_DOLLAR;
870 378 : }
871 : function yy_r3_73($yy_subpatterns)
872 : {
873 :
874 7 : $this->token = Smarty_Compiler_Template_Parser::TP_SEMICOLON;
875 7 : }
876 : function yy_r3_74($yy_subpatterns)
877 : {
878 :
879 12 : $this->token = Smarty_Compiler_Template_Parser::TP_DOUBLECOLON;
880 12 : }
881 : function yy_r3_75($yy_subpatterns)
882 : {
883 :
884 124 : $this->token = Smarty_Compiler_Template_Parser::TP_COLON;
885 124 : }
886 : function yy_r3_76($yy_subpatterns)
887 : {
888 :
889 18 : $this->token = Smarty_Compiler_Template_Parser::TP_AT;
890 18 : }
891 : function yy_r3_77($yy_subpatterns)
892 : {
893 :
894 17 : $this->token = Smarty_Compiler_Template_Parser::TP_HATCH;
895 17 : }
896 : function yy_r3_78($yy_subpatterns)
897 : {
898 :
899 325 : $this->token = Smarty_Compiler_Template_Parser::TP_QUOTE;
900 325 : $this->yypushstate(self::DOUBLEQUOTEDSTRING);
901 325 : }
902 : function yy_r3_79($yy_subpatterns)
903 : {
904 :
905 8 : $this->token = Smarty_Compiler_Template_Parser::TP_BACKTICK;
906 8 : $this->yypopstate();
907 8 : }
908 : function yy_r3_80($yy_subpatterns)
909 : {
910 :
911 176 : $this->token = Smarty_Compiler_Template_Parser::TP_VERT;
912 176 : }
913 : function yy_r3_81($yy_subpatterns)
914 : {
915 :
916 37 : $this->token = Smarty_Compiler_Template_Parser::TP_DOT;
917 37 : }
918 : function yy_r3_82($yy_subpatterns)
919 : {
920 :
921 55 : $this->token = Smarty_Compiler_Template_Parser::TP_COMMA;
922 55 : }
923 : function yy_r3_83($yy_subpatterns)
924 : {
925 :
926 0 : $this->token = Smarty_Compiler_Template_Parser::TP_ANDSYM;
927 0 : }
928 : function yy_r3_84($yy_subpatterns)
929 : {
930 :
931 21 : $this->token = Smarty_Compiler_Template_Parser::TP_QMARK;
932 21 : }
933 : function yy_r3_85($yy_subpatterns)
934 : {
935 :
936 0 : $this->token = Smarty_Compiler_Template_Parser::TP_HEX;
937 0 : }
938 : function yy_r3_86($yy_subpatterns)
939 : {
940 :
941 : // resolve conflicts with shorttag and right_delimiter starting with '='
942 340 : if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->compiler->tpl_obj->right_delimiter) {
943 1 : preg_match("/\s+/",$this->value,$match);
944 1 : $this->value = $match[0];
945 1 : $this->token = Smarty_Compiler_Template_Parser::TP_SPACE;
946 1 : } else {
947 340 : $this->token = Smarty_Compiler_Template_Parser::TP_ATTR;
948 : }
949 340 : }
950 : function yy_r3_87($yy_subpatterns)
951 : {
952 :
953 802 : $this->token = Smarty_Compiler_Template_Parser::TP_ID;
954 802 : }
955 : function yy_r3_88($yy_subpatterns)
956 : {
957 :
958 300 : $this->token = Smarty_Compiler_Template_Parser::TP_INTEGER;
959 300 : }
960 : function yy_r3_89($yy_subpatterns)
961 : {
962 :
963 50 : $this->token = Smarty_Compiler_Template_Parser::TP_SPACE;
964 50 : }
965 : function yy_r3_90($yy_subpatterns)
966 : {
967 :
968 0 : $this->token = Smarty_Compiler_Template_Parser::TP_NAMESPACE;
969 0 : }
970 : function yy_r3_92($yy_subpatterns)
971 : {
972 :
973 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
974 0 : }
975 :
976 :
977 :
978 : public function yylex4()
979 : {
980 : $tokenMap = array (
981 0 : 1 => 0,
982 0 : 2 => 0,
983 0 : 3 => 0,
984 0 : 4 => 0,
985 0 : 5 => 0,
986 0 : 6 => 0,
987 0 : 7 => 0,
988 0 : );
989 0 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
990 0 : return false; // end of input
991 : }
992 0 : $yy_global_pattern = "/\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G([\S\s])/iS";
993 :
994 : do {
995 0 : if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
996 0 : $yysubmatches = $yymatches;
997 0 : $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
998 0 : if (!count($yymatches)) {
999 0 : throw new Exception('Error: lexing failed because a rule matched' .
1000 0 : ' an empty string. Input "' . substr($this->data,
1001 0 : $this->counter, 5) . '... state LITERAL');
1002 : }
1003 0 : next($yymatches); // skip global match
1004 0 : $this->token = key($yymatches); // token number
1005 0 : if ($tokenMap[$this->token]) {
1006 : // extract sub-patterns for passing to lex function
1007 0 : $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1008 0 : $tokenMap[$this->token]);
1009 0 : } else {
1010 0 : $yysubmatches = array();
1011 : }
1012 0 : $this->value = current($yymatches); // token value
1013 0 : $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
1014 0 : if ($r === null) {
1015 0 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
1016 0 : $this->line += substr_count($this->value, "\n");
1017 : // accept this token
1018 0 : return true;
1019 0 : } elseif ($r === true) {
1020 : // we have changed state
1021 : // process this token in the new state
1022 0 : return $this->yylex();
1023 0 : } elseif ($r === false) {
1024 0 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
1025 0 : $this->line += substr_count($this->value, "\n");
1026 0 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
1027 0 : return false; // end of input
1028 : }
1029 : // skip this token
1030 0 : continue;
1031 0 : } } else {
1032 0 : throw new Exception('Unexpected input at line' . $this->line .
1033 0 : ': ' . $this->data[$this->counter]);
1034 : }
1035 0 : break;
1036 0 : } while (true);
1037 :
1038 0 : } // end function
1039 :
1040 :
1041 : const LITERAL = 4;
1042 : function yy_r4_1($yy_subpatterns)
1043 : {
1044 :
1045 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LITERALSTART;
1046 0 : $this->yypushstate(self::LITERAL);
1047 0 : }
1048 : function yy_r4_2($yy_subpatterns)
1049 : {
1050 :
1051 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LITERALEND;
1052 0 : $this->yypopstate();
1053 0 : }
1054 : function yy_r4_3($yy_subpatterns)
1055 : {
1056 :
1057 0 : if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
1058 0 : $this->token = Smarty_Compiler_Template_Parser::TP_PHPSTARTTAG;
1059 0 : } else {
1060 0 : $this->token = Smarty_Compiler_Template_Parser::TP_FAKEPHPSTARTTAG;
1061 0 : $this->value = substr($this->value, 0, 2);
1062 : }
1063 0 : }
1064 : function yy_r4_4($yy_subpatterns)
1065 : {
1066 :
1067 0 : $this->token = Smarty_Compiler_Template_Parser::TP_PHPENDTAG;
1068 0 : }
1069 : function yy_r4_5($yy_subpatterns)
1070 : {
1071 :
1072 0 : $this->token = Smarty_Compiler_Template_Parser::TP_ASPSTARTTAG;
1073 0 : }
1074 : function yy_r4_6($yy_subpatterns)
1075 : {
1076 :
1077 0 : $this->token = Smarty_Compiler_Template_Parser::TP_ASPENDTAG;
1078 0 : }
1079 : function yy_r4_7($yy_subpatterns)
1080 : {
1081 :
1082 0 : if ($this->mbstring_overload) {
1083 0 : $to = mb_strlen($this->data,'latin1');
1084 0 : } else {
1085 0 : $to = strlen($this->data);
1086 : }
1087 0 : preg_match("/{$this->ldel}\/?literal{$this->rdel}|<\?|<%|\?>|%>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
1088 0 : if (isset($match[0][1])) {
1089 0 : $to = $match[0][1];
1090 0 : } else {
1091 0 : $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
1092 : }
1093 0 : if ($this->mbstring_overload) {
1094 0 : $this->value = mb_substr($this->data,$this->counter,$to-$this->counter,'latin1');
1095 0 : } else {
1096 0 : $this->value = substr($this->data,$this->counter,$to-$this->counter);
1097 : }
1098 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LITERAL;
1099 0 : }
1100 :
1101 :
1102 : public function yylex5()
1103 : {
1104 : $tokenMap = array (
1105 325 : 1 => 1,
1106 325 : 3 => 2,
1107 325 : 6 => 1,
1108 325 : 8 => 1,
1109 325 : 10 => 1,
1110 325 : 12 => 1,
1111 325 : 14 => 1,
1112 325 : 16 => 0,
1113 325 : 17 => 0,
1114 325 : 18 => 0,
1115 325 : 19 => 0,
1116 325 : 20 => 3,
1117 325 : 24 => 0,
1118 325 : );
1119 325 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
1120 0 : return false; // end of input
1121 : }
1122 325 : $yy_global_pattern = "/\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s{1,}\/)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*(if|elseif|else if|while)\\s+)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*for\\s+)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s*foreach(?![^\s]))|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\\s{1,})|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel.")\/)|\G((\\s*".$this->ldel."--|[^\S\r\n]*".$this->ldel."-|".$this->ldel."))|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|\G([\S\s])/iS";
1123 :
1124 : do {
1125 325 : if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
1126 325 : $yysubmatches = $yymatches;
1127 325 : $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
1128 325 : if (!count($yymatches)) {
1129 0 : throw new Exception('Error: lexing failed because a rule matched' .
1130 0 : ' an empty string. Input "' . substr($this->data,
1131 0 : $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
1132 : }
1133 325 : next($yymatches); // skip global match
1134 325 : $this->token = key($yymatches); // token number
1135 325 : if ($tokenMap[$this->token]) {
1136 : // extract sub-patterns for passing to lex function
1137 312 : $yysubmatches = array_slice($yysubmatches, $this->token + 1,
1138 312 : $tokenMap[$this->token]);
1139 312 : } else {
1140 325 : $yysubmatches = array();
1141 : }
1142 325 : $this->value = current($yymatches); // token value
1143 325 : $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
1144 325 : if ($r === null) {
1145 325 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
1146 325 : $this->line += substr_count($this->value, "\n");
1147 : // accept this token
1148 325 : return true;
1149 0 : } elseif ($r === true) {
1150 : // we have changed state
1151 : // process this token in the new state
1152 0 : return $this->yylex();
1153 0 : } elseif ($r === false) {
1154 0 : $this->counter += ($this->mbstring_overload ? mb_strlen($this->value,'latin1'): strlen($this->value));
1155 0 : $this->line += substr_count($this->value, "\n");
1156 0 : if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
1157 0 : return false; // end of input
1158 : }
1159 : // skip this token
1160 0 : continue;
1161 0 : } } else {
1162 0 : throw new Exception('Unexpected input at line' . $this->line .
1163 0 : ': ' . $this->data[$this->counter]);
1164 : }
1165 0 : break;
1166 0 : } while (true);
1167 :
1168 0 : } // end function
1169 :
1170 :
1171 : const DOUBLEQUOTEDSTRING = 5;
1172 : function yy_r5_1($yy_subpatterns)
1173 : {
1174 :
1175 0 : if ($this->compiler->tpl_obj->auto_literal) {
1176 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1177 0 : } else {
1178 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELSLASH;
1179 0 : $this->yypushstate(self::SMARTY);
1180 0 : $this->taglineno = $this->line + $this->line_offset;
1181 : }
1182 0 : }
1183 : function yy_r5_3($yy_subpatterns)
1184 : {
1185 :
1186 1 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1187 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1188 0 : } else {
1189 1 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELIF;
1190 1 : $this->yypushstate(self::SMARTY);
1191 1 : $this->taglineno = $this->line + $this->line_offset;
1192 : }
1193 1 : }
1194 : function yy_r5_6($yy_subpatterns)
1195 : {
1196 :
1197 0 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1198 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1199 0 : } else {
1200 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELFOR;
1201 0 : $this->yypushstate(self::SMARTY);
1202 0 : $this->taglineno = $this->line + $this->line_offset;
1203 : }
1204 0 : }
1205 : function yy_r5_8($yy_subpatterns)
1206 : {
1207 :
1208 0 : if ($this->compiler->tpl_obj->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
1209 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1210 0 : } else {
1211 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELFOREACH;
1212 0 : $this->yypushstate(self::SMARTY);
1213 0 : $this->taglineno = $this->line + $this->line_offset;
1214 : }
1215 0 : }
1216 : function yy_r5_10($yy_subpatterns)
1217 : {
1218 :
1219 2 : if ($this->compiler->tpl_obj->auto_literal) {
1220 2 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1221 2 : } else {
1222 0 : $this->token = Smarty_Compiler_Template_Parser::TP_LDEL;
1223 0 : $this->yypushstate(self::SMARTY);
1224 0 : $this->taglineno = $this->line + $this->line_offset;
1225 : }
1226 2 : }
1227 : function yy_r5_12($yy_subpatterns)
1228 : {
1229 :
1230 1 : $this->token = Smarty_Compiler_Template_Parser::TP_LDELSLASH;
1231 1 : $this->yypushstate(self::SMARTY);
1232 1 : $this->taglineno = $this->line + $this->line_offset;
1233 1 : }
1234 : function yy_r5_14($yy_subpatterns)
1235 : {
1236 :
1237 7 : $this->token = Smarty_Compiler_Template_Parser::TP_LDEL;
1238 7 : $this->yypushstate(self::SMARTY);
1239 7 : $this->taglineno = $this->line + $this->line_offset;
1240 7 : }
1241 : function yy_r5_16($yy_subpatterns)
1242 : {
1243 :
1244 325 : $this->token = Smarty_Compiler_Template_Parser::TP_QUOTE;
1245 325 : $this->yypopstate();
1246 325 : }
1247 : function yy_r5_17($yy_subpatterns)
1248 : {
1249 :
1250 8 : $this->token = Smarty_Compiler_Template_Parser::TP_BACKTICK;
1251 8 : $this->value = substr($this->value,0,-1);
1252 8 : $this->yypushstate(self::SMARTY);
1253 8 : $this->taglineno = $this->line + $this->line_offset;
1254 8 : }
1255 : function yy_r5_18($yy_subpatterns)
1256 : {
1257 :
1258 2 : $this->token = Smarty_Compiler_Template_Parser::TP_DOLLARID;
1259 2 : }
1260 : function yy_r5_19($yy_subpatterns)
1261 : {
1262 :
1263 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1264 0 : }
1265 : function yy_r5_20($yy_subpatterns)
1266 : {
1267 :
1268 312 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1269 312 : }
1270 : function yy_r5_24($yy_subpatterns)
1271 : {
1272 :
1273 0 : if ($this->mbstring_overload) {
1274 0 : $to = mb_strlen($this->data,'latin1');
1275 0 : } else {
1276 0 : $to = strlen($this->data);
1277 : }
1278 0 : if ($this->mbstring_overload) {
1279 0 : $this->value = mb_substr($this->data,$this->counter,$to-$this->counter,'latin1');
1280 0 : } else {
1281 0 : $this->value = substr($this->data,$this->counter,$to-$this->counter);
1282 : }
1283 0 : $this->token = Smarty_Compiler_Template_Parser::TP_TEXT;
1284 0 : }
1285 :
1286 : }
|